Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Mi función devuelve "[promesa de objeto]" como resultado (después del tiempo de espera). Pero cuando se usa la función, la consola ya está registrando el resultado (steamID) JS

Lo probé sin el tiempo de espera, sin transferir el SteamID a una cadena (ambos "No se puede enviar un mensaje vacío") y un poco más. Pero no he llegado más lejos en unos 30 minutos.

(vanityURL = entrada)

Mi función (la API funciona completamente):

 const fetch = require("node-fetch"); const botconfig = require("../botconfig.json") async function getSteamID(vanityURL) { const response = await fetch(`https://api.steampowered.com/ISteamUser/ResolveVanityURL/v1/?key=${botconfig.steamapikey}&vanityurl=${vanityURL}`); const data = await response.json(); const listDataRaw = JSON.stringify(data); const listData = listDataRaw.toString(); var steamID = listData.replace(/{"response":{"steamid":"|","success":1}}/g, "") // Filter console.log(steamID) return steamID; } module.exports = { getSteamID }

Mi comando de prueba:

 const getSteamInfo = require('../functions/getSteamInfo'); module.exports.run = async (bot, message, args) => { var vanityURL = args.join(' ') const rawSteamID = getSteamInfo.getSteamID(vanityURL); await new Promise(r => setTimeout(r, 1000)); let steamID = rawSteamID.toString(); message.channel.send(steamID) }; module.exports.command = { name: `test` }

¡Gracias por la ayuda!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Simplemente ponga "await" const rawSteamID = await getSteamInfo.getSteamID(vanityURL);

y ver que está funcionando

about 4 years ago · Juan Pablo Isaza Report

0

Olvidó await su llamada a getSteamInfo.getSteamID .

(También olvidó await la llamada a message.channel.send , por lo que en este momento cualquier error que arroje se convertiría en un rechazo no manejado).

 const getSteamInfo = require('../functions/getSteamInfo'); module.exports.run = async (bot, message, args) => { const vanityURL = args.join(' ') const rawSteamID = await getSteamInfo.getSteamID(vanityURL) // ^^^^^ const steamID = rawSteamID.toString() // not sure this is even needed...? await message.channel.send(steamID) //^^^ } module.exports.command = { name: `test` }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!